package com.jay.lang.reflect.intf;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
import java.util.List;
import java.util.Set;

public class WildcardTypeIntf {

	public static void main(String[] args) throws NoSuchMethodException,
			SecurityException {
		Method getPayments = WildcardTypeIntf.class.getMethod("getPayments",
				new Class[] { String[].class, Set.class });
		Type[] types = getPayments.getGenericParameterTypes();
		if (types[1] instanceof ParameterizedType) {
			System.out
					.println("The second parameter of this method is ParameterizedType.");
			ParameterizedType gType = (ParameterizedType) types[1];
			Type t = gType.getActualTypeArguments()[0];
			System.out.println(t);
			if (t instanceof WildcardType) {
				System.out.println("The type is a wildcard.");
				System.out.println(((WildcardType) t).getLowerBounds()[0]);
				System.out.println(((WildcardType) t).getUpperBounds()[0]);
			}
			System.out.println(gType.getOwnerType());
			System.out.println(gType.getRawType());
		}
	}

	public String[] getPayments(String[] payments,
			Set<? super List<String>> products) {
		return payments;
	}

}
